}
/* Optionally flush file to disk and discard page cache */
-int discard_file_cache(int fd, int flush)
+void discard_file_cache(int fd, int flush)
{
off_t cur = 0;
+ int saved_errno = errno;
if ( flush && (fsync(fd) < 0) )
{
- PERROR("Failed to flush file: %s", strerror(errno));
- return -errno;
+ /*PERROR("Failed to flush file: %s", strerror(errno));*/
+ goto out;
}
/*
/* Discard from the buffer cache. */
if ( posix_fadvise64(fd, 0, cur, POSIX_FADV_DONTNEED) < 0 )
{
- PERROR("Failed to discard cache: %s", strerror(errno));
- return -errno;
+ /*PERROR("Failed to discard cache: %s", strerror(errno));*/
+ goto out;
}
- return 0;
+ out:
+ errno = saved_errno;
}
/*
int rc = write(fd,buffer,len);
- if (!live) {
- write_count += len;
+ write_count += len;
- if (write_count >= MAX_PAGECACHE_USAGE*PAGE_SIZE) {
- int serrno = errno;
-
- /* Time to discard cache - dont care if this fails */
- discard_file_cache(fd, 0 /* no flush */);
-
- write_count = 0;
-
- errno = serrno;
- }
+ if (write_count >= MAX_PAGECACHE_USAGE*PAGE_SIZE) {
+ /* Time to discard cache - dont care if this fails */
+ discard_file_cache(fd, 0 /* no flush */);
+ write_count = 0;
}
+
return rc;
}
DPRINTF("Warning - couldn't disable shadow mode");
}
}
- else {
- // flush last write and discard cache for file
- discard_file_cache(io_fd, 1 /* flush */);
- }
+
+ // flush last write and discard cache for file
+ discard_file_cache(io_fd, 1 /* flush */);
if (live_shinfo)
munmap(live_shinfo, PAGE_SIZE);
if (live_p2m_frame_list)
munmap(live_p2m_frame_list, P2M_FLL_ENTRIES * PAGE_SIZE);
- if(live_p2m)
+ if (live_p2m)
munmap(live_p2m, P2M_SIZE);
- if(live_m2p)
+ if (live_m2p)
munmap(live_m2p, M2P_SIZE(max_mfn));
free(pfn_type);
void bitmap_byte_to_64(uint64_t *lp, const uint8_t *bp, int nbits);
/* Optionally flush file to disk and discard page cache */
-int discard_file_cache(int fd, int flush);
+void discard_file_cache(int fd, int flush);
#endif /* __XC_PRIVATE_H__ */
}
/* Optionally flush file to disk and discard page cache */
-int discard_file_cache(int fd, int flush)
+void discard_file_cache(int fd, int flush)
{
// TODO: Implement for Solaris!
- return 0;
}